<?php
/* @var $this PostsController */
/* @var $model Posts */

$this->breadcrumbs = array(
    '内容管理' => array('admin'),
    '列表',
);

$items = array();

foreach ($categorys as $c) {
    if (isset($c['subs']) && !empty($c['subs'])) {

        $subItems = array();
        foreach ($c['subs'] as $sc) {
            $subItems[] = array(
                'label' => $sc['category_name'],
                'url' => array('posts/admin', 'category_id' => $sc['id']),
            );
        }
        $items[] = array(
            'label' => $c['category_name'],
            'url' => array('posts/admin', 'category_id' => $c['id']),
            'items' => $subItems,
        );
    } else {

        $items[] = array(
            'label' => $c['category_name'],
            'url' => array('posts/admin', 'category_id' => $c['id']),
        );
    }
}
$items[] = array(
    'label' => '栏目管理',
    'url' => array('categorys/admin')
);
$items[] = array('label' => '高级搜索', 'url' => 'javascript:void(0)', 'linkOptions' => array('class' => 'search-button'));


$this->menu = $items;

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('posts-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>
<div>
    <h1 style="float:left;"><?php echo !empty($category) ? $category->category_name : '所有内容';?></h1>  
<?php
if (isset($_GET['category_id'])):
    ?>
        <a class="button01" style="display:block;float:right;" href="<?php echo $this->createUrl('create', array('category_id' => $_GET['category_id'])); ?>">发布内容</a>
        <?php
    endif;
    ?>
        <div class="clear"></div>
</div>


<div class="search-form" style="display:none">
<?php
$this->renderPartial('_search', array(
    'model' => $model,
));
?>
</div><!-- search-form -->

<?php
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'posts-grid',
    'ajaxUpdate' => false,
    'dataProvider' => $model->search(),
    //'filter'=>$model,
    'columns' => array(
        'id',
        'post_title',
        'post_date',
        'post_model',
        'post_alias',
        'show_num',
        'post_status',
        /*
          
          'post_uid',
          'post_status',
          'seo_title',
          'seo_keywords',
          'seo_description',
          'comment_status',
          'comment_count',
          'show_num',
         */
        array(
            'class' => 'CButtonColumn',
        ),
    ),
));
?>
